package org.zhaozhen.basic.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zhaozhen.basic.businessexception.BusinessException;
import org.zhaozhen.basic.service.IVerifyCodeService;
import org.zhaozhen.basic.util.AjaxResult;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService verifyCodeService;

    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody Map<String,String> obj){
        try {
            verifyCodeService.sendSmsCode(obj);
            return AjaxResult.me();
        }
        catch (BusinessException e){
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage(e.getMessage());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("你操作错了，和我们没关系哈");
        }
    }
}
